package com.mycompany.project.server.model;
import java.util.List;
import java.util.LinkedList;

/*Selection class is defined by: Cartesian coordinations, height, width, temporal persistence.
   For each video selection, 1..* annotations correspond.
   Aggiungere il tempo di inizio e fine della selezione. Le selection vanno ordinate in base al tempo di inizio*/

public class SelectionModel implements Comparable<SelectionModel> {
	
	private VideoModel video;
	private float selX;
	private float selY;
	private float selH;
	private float selW;
	private int endTime;
	private int startTime;
	private ResolutionModel resolution;    
	private List <AnnotationModel> annotations = new LinkedList<AnnotationModel>();
	
	TimeModel time = new TimeModel();
	
	public SelectionModel(){
		
	}

	//Constructor
	public SelectionModel(VideoModel video, float selX, float selY, float selH, float selW, int endTime, int startTime, ResolutionModel resolution, List<AnnotationModel> annotations){
		this.video = video;
	    this.selX = selX;
	    this.selY = selY;
		this.selH = selH;
		this.selW = selW;
		this.endTime = endTime;
		this.startTime = startTime;
		this.resolution = resolution;
		this.annotations = annotations;
	}
	
	public SelectionModel(int startTime){
		this.startTime = startTime;
	}

    //Accessible methods
	public void setVideo(VideoModel video) {
		this.video = video;
	}

	public VideoModel getVideo() {
		return video;
	}
	
	public void setSelX(float selX) {
		this.selX = selX;
	}

	public float getSelX() {
		return selX;
	}

	public void setSelY(float selY) {
		this.selY = selY;
	}

	public float getSelY() {
		return selY;
	}

	public void setSelH(float selH) {
		this.selH = selH;
	}

	public float getSelH() {
		return selH;
	}

	public void setSelW(float selW) {
		this.selW = selW;
	}

	public float getSelW() {
		return selW;
	}
	
	public void setEndTime(int endTime) {
		this.endTime = endTime;
	}

	public int getEndTime() {
		return endTime;
	}

	public void setStartTime(int startTime) {
		this.startTime = startTime;
	}

	public int getStartTime() {
		return startTime;
	} 
	
	public void setAnnotations(List <AnnotationModel> annotations) {
		this.annotations = annotations;
	}

	public List <AnnotationModel> getAnnotations() {
		return annotations;
	}

	public void setResolution(ResolutionModel resolution) {
		this.resolution = resolution;
	}

	public ResolutionModel getResolution() {
		return resolution;
	}
	
	public int startTimeCompute(){
		this.startTime = time.getTime();
		return this.startTime;
	}
	
	public int endTimeCompute(){
		this.endTime = time.getTime();
		return this.endTime;
	}
	
	public int persistenceCompute(){
		this.startTime = time.getTime();
		this.endTime = time.getTime();
		int persistence = (this.startTime - this.endTime);
		return persistence;
	}
	
	@Override
	public int compareTo(SelectionModel sM) {
		if (this.getStartTime() < ((SelectionModel)sM).getStartTime())
			return -1;
		else if
		   (this.getStartTime() > ((SelectionModel)sM).getStartTime())
			return 1;
		else
			return 0;
	}
	
	

}

